package main

import (
	"data_struct/ArrayList"
	"data_struct/StackArray"
	"fmt"
)

func main1() {
	list := ArrayList.NewArrayList()
	list.Append(1)
	list.Append(2)
	list.Append(3)
	fmt.Println(list)
}

func main2() {
	list := ArrayList.NewArrayList()
	list.Append("a")
	list.Append("b")
	list.Append("c")
	fmt.Println(list.TheSize)
}

func main3() {
	//定义接口对象，必须实现所有接口方法
	var list ArrayList.List = ArrayList.NewArrayList()
	list.Append("a")
	list.Append("b")
	list.Append("c")
}

func main4() {
	//定义接口对象，必须实现所有接口方法
	var list ArrayList.List = ArrayList.NewArrayList()
	list.Append("a")
	list.Append("b")
	list.Append("c")
	for i := 0; i < 4; i++ {
		list.Insert(1, "x5")
		fmt.Println(list)
	}
	fmt.Println("delete")
	list.Delete(2) //删除
	fmt.Println(list)
}

func main5() {
	//定义接口对象，必须实现所有接口方法
	var list ArrayList.List = ArrayList.NewArrayList()
	list.Append("a")
	list.Append("b")
	list.Append("c")
	for i := 0; i < 100; i++ { //原有的数据没有拷贝过来
		list.Insert(1, "x5")
		fmt.Println(list)
	}
	fmt.Println(list)
}

func main6() {
	//定义接口对象，必须实现所有接口方法
	var list ArrayList.List = ArrayList.NewArrayList()
	list.Append("a")
	list.Append("b")
	list.Append("c")
	list.Append("e")
	list.Append("f")
	for it := list.Iterator(); it.HasNext(); {
		item, _ := it.Next("111111")
		if item == "c" {
			it.Remove()
		}
		fmt.Println(item)
	}
	fmt.Println(list)
}

func main7() {
	mystack := StackArray.NewStack()
	mystack.Push(1)
	mystack.Push(2)
	mystack.Push(3)
	mystack.Push(4)
	fmt.Println(mystack.Pop())
	fmt.Println(mystack.Pop())
	fmt.Println(mystack.Pop())
	fmt.Println(mystack.Pop())
}

func main() {
	mystack := ArrayList.NewArrayListStackX()
	mystack.Push(1)
	mystack.Push(2)
	mystack.Push(3)
	mystack.Push(4)
	fmt.Println(mystack.Pop())
	fmt.Println(mystack.Pop())
	fmt.Println(mystack.Pop())
	fmt.Println(mystack.Pop())

	for it := mystack.Myit; it.HasNext(); {
		item, _ := it.Next("111111")
		fmt.Println(item)
	}
}